package logic

import (
	"context"
	"go_zero_list/mode"

	"go_zero_list/doctor_rpc/doctor_rpc"
	"go_zero_list/doctor_rpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLogic {
	return &GetLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GetLogic) Get(in *doctor_rpc.GetRequest) (*doctor_rpc.GetResponse, error) {
	// todo: add your logic here and delete this line
	var doctor mode.Doctor
	doctor.ID = uint(in.Id)
	if err := doctor.GetDoctorByID(); err != nil {
		return &doctor_rpc.GetResponse{Doctor: nil}, err
	}
	return &doctor_rpc.GetResponse{Doctor: &doctor_rpc.DoctorStruct{
		Id:      int64(doctor.ID),
		Name:    doctor.Name,
		Image:   doctor.Image,
		FormHos: doctor.FormHos,
		Title:   doctor.Title,
		FormDep: doctor.FormDep,
		Des:     doctor.Des,
	}}, nil
}
